package com.guchenbo.example.lock;

import com.guchenbo.example.thread.WaitTest;

/**
 * Created by CreGu on 2016/6/21.
 */
public class WaitTest1 {
    static Object obj=new Object();
    public static void main(String[] args) {
        Thread mainThread = Thread.currentThread();
        OtherThread oo = new OtherThread();
        OtherThread oo2 = new OtherThread();
        Thread ot = new Thread(oo);

        synchronized (oo2) {
            System.out.println(mainThread + "wait");
//            try {
                ot.start();
//                oo2.wait();
                System.out.println(mainThread+"continue");
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
        }
    }

    static class OtherThread implements Runnable{

        @Override
        public void run() {
            WaitTest w = new WaitTest();
            synchronized (w) {
                w.notify();
                System.out.println(Thread.currentThread()+"notify");

            }try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("end");
        }
    }
}